-
Notifications
You must be signed in to change notification settings - Fork 29
chore(swagger): automate swagger sync to amrit-docs #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughAdds a Swagger profile and a GitHub Actions workflow that builds the API, runs it to export /v3/api-docs as JSON, and opens a PR to update the AMRIT-Docs repo; also adds an H2 dependency and disables Redis and an HTTP interceptor when the swagger profile is active. Changes
Sequence Diagram(s)sequenceDiagram
participant Actions as "GitHub Actions"
participant Repo as "API repo (checkout)"
participant Builder as "Java/Maven build"
participant API as "ECD API (run with swagger)"
participant jq as "jq/validator"
participant DocsRepo as "AMRIT-Docs (checkout)"
participant GitHub as "GitHub (create PR)"
Actions->>Repo: checkout API code
Actions->>Builder: setup Java 17 + Maven cache\nmvn -DskipTests package
Actions->>API: run app with profile=swagger (port 9090)
loop poll /v3/api-docs
Actions->>API: GET /v3/api-docs
API-->>Actions: JSON response
Actions->>jq: validate & save as ecd-api.json
end
Actions->>API: stop process (kill PID)
Actions->>DocsRepo: checkout AMRIT-Docs using token
Actions->>DocsRepo: copy ecd-api.json -> docs/swagger/ecd-api.json\ncommit changes
Actions->>GitHub: create pull request with commit/PR body
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/main/resources/application-swagger.properties`:
- Line 24: The jwt.secret property value contains a leading space; update the
property key jwt.secret so its value has no leading or trailing whitespace
(change " JWT_SECRET" to "JWT_SECRET") to ensure the secret is read correctly by
the application (verify trim or no surrounding quotes if any).
🧹 Nitpick comments (1)
.github/workflows/swagger-json.yml (1)
37-56: Consider adding an initial delay before polling.Spring Boot applications typically take 10-30 seconds to start. Adding an initial sleep before the polling loop could reduce unnecessary failed attempts and improve reliability.
Proposed improvement
- name: Wait for API & fetch Swagger run: | + echo "Waiting for Spring Boot to initialize..." + sleep 15 for i in {1..30}; do CODE=$(curl --connect-timeout 2 --max-time 5 -s -o swagger_raw.json -w "%{http_code}" http://localhost:9090/v3/api-docs || true)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/main/resources/application-swagger.properties`:
- Line 9: The spring.jpa.hibernate.ddl-auto property is set to "none" which
causes failures on an empty in-memory H2 DB; change the value of
spring.jpa.hibernate.ddl-auto from "none" to "create-drop" (or "create") in the
application-swagger.properties so the schema is created at startup and removed
on shutdown, ensuring JPA entities and any `@PostConstruct/CommandLineRunner`
repository calls won't fail at boot.
🧹 Nitpick comments (4)
src/main/resources/application-swagger.properties (1)
11-13: Redis properties are unnecessary whenRedisConfigis profile-excluded.
RedisConfigis annotated with@Profile("!swagger"), so no Redis beans are created under this profile. These properties are dead config. Removing them avoids confusion about whether Redis is actually used..github/workflows/swagger-json.yml (3)
3-6: Workflow triggers on every push tomain— consider filtering by relevant paths.Every merge to
main(including doc-only or config changes) will trigger a full build + swagger export. Adding apathsfilter reduces unnecessary CI runs.Suggested filter
on: push: branches: [ main ] + paths: + - 'src/**' + - 'pom.xml' workflow_dispatch:
27-28:jqis pre-installed onubuntu-latestrunners.This step can be removed to save a few seconds. If you'd like to keep it for safety, that's fine too.
67-80: Process group kill (kill -- -$PID) may not work as intended.
$!captures the PID of the backgroundedjavaprocess, butkill -- -$PIDsends a signal to the process group whose PGID equals$PID. In GitHub Actions, the background process may not be a process group leader, so this could silently miss. Thefuser -k 9090/tcpfallback on line 80 covers it, but you could simplify:Simplified stop logic
- name: Stop API if: always() run: | - # Graceful shutdown of the process group - sleep 5 - # Force kill the process group if still running if [ -f api_pid.txt ]; then - PID=$(cat api_pid.txt) - kill -TERM -- -"$PID" 2>/dev/null || true - sleep 2 - kill -9 -- -"$PID" 2>/dev/null || true - fi - # Fallback: kill any remaining java process on port 9090 - fuser -k 9090/tcp 2>/dev/null || true + PID=$(cat api_pid.txt) + kill "$PID" 2>/dev/null || true + sleep 5 + kill -9 "$PID" 2>/dev/null || true + fi + fuser -k 9090/tcp 2>/dev/null || true
|



Summary by CodeRabbit